package com.gf.pf.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.gf.pf.model.Job;

/**
 * @describe 角色
 * @date     2015年3月7日
 */
public interface JobMapper {

	/**
	 * 根据用户ID查询职位SQL
	 */
	final String GET_BY_USERID = "SELECT * FROM sys_job WHERE job_isvalid = 1 and job_id IN (SELECT job_id FROM sys_user_job WHERE user_id = #{userId})";
	
	/**
	 * 保存职位SQL
	 */
	final String SAVE_JOB = "INSERT INTO sys_job VALUES(#{id}, #{jobName}, #{jobMemo}, ${jobOrderno}, ${jobIsvalid})";
	
	/**
	 * 根据职位ID查询职位信息SQL
	 */
	final String GET_JOB_BY_ID = "SELECT job_id as id, job_name, job_memo, job_orderno, job_isvalid FROM sys_job WHERE job_id = #{jobId}";
	
	/**
	 * 修改职位SQL
	 */
	final String MODIFY_JOB_BY_ID = "UPDATE sys_job SET job_name = #{jobName}, job_memo = #{jobMemo}, job_orderno = ${jobOrderno}, job_isvalid = ${jobIsvalid} WHERE job_id = #{id}";
	
	/**
	 * 删除职位SQL
	 */
	final String DELETE_JOB_BY_ID = "DELETE FROM sys_job WHERE job_id = #{jobId}";
	
	/**
	 * 
	 * @describe 根据用户ID查询职位
	 * @param userId
	 * @return
	 */
	@Select(GET_BY_USERID)
	List<Job> getJobs(String userId);
	
	/**
	 * 
	 * @description 保存职位
	 * @return Integer
	 */
	@Insert(SAVE_JOB)
	Integer saveJob(Job job);
	
	/**
	 * 
	 * @description 根据职位ID查询职位信息
	 * @return Job
	 */
	@Select(GET_JOB_BY_ID)
	Job getJob(String jobId);
	
	/**
	 * 
	 * @description 修改职位
	 * @return Integer
	 */
	@Update(MODIFY_JOB_BY_ID)
	Integer modifyJob(Job job);
	
	/**
	 * 
	 * @description 删除职位
	 * @return Integer
	 */
	@Delete(DELETE_JOB_BY_ID)
	Integer deleteJob(String jobId);
}
